#coding:utf-8
#file:PyGTKButtonEvent.py
import pygtk
pygtk.require('2.0')
import gtk

class MyWindow:
    def __init__(self, title, width, height):
        self.window = gtk.Window()
        self.window.set_title(title)
        self.window.set_default_size(width, height)
        self.window.connect('destroy', lambda q: gtk.main_quit())

        hbox = gtk.HBox(False, 20)
        self.button1 = gtk.Button('Button1')
        self.button2 = gtk.Button('Button2')
        self.button1.connect('clicked', self.OnButton1, 'Button1')

        self.button2.connect('clicked', self.OnButton2, 'Button2')
        hbox.pack_start(self.button1)
        hbox.pack_start(self.button2)
        self.window.add(hbox)
        hbox.show()
        self.button1.show()
        self.button2.show()
        self.window.show()

    def main(self):
        gtk.main()

    def OnButton1(self, widget, data):
        self.button2.set_label('Quit')

    def OnButton2(self, widget, data):
        gtk.main_quit()

if __name__ == '__main__':
    window = MyWindow('PyGTK', 150, 30)
    window.main()
